package com.demo.test.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.bluering.framework.common.base.BaseService;
import com.bluering.framework.common.log.Logger;
import com.demo.test.repository.mapper.OcsIssuerMapper;
import com.demo.test.repository.model.OcsIssuer;
import com.demo.test.service.IOcsIssuerService;

@Service
@CacheConfig(cacheNames = "ocsIssuer")
@Transactional(rollbackFor=Exception.class,propagation=Propagation.REQUIRED)
public class OcsIssuerServiceImpl extends BaseService<OcsIssuer> implements IOcsIssuerService {
	
	private static Logger logger =Logger.getLogger(OcsIssuerServiceImpl.class);
	
	@Autowired
	private OcsIssuerMapper ocsIssuerMapper;

	@Cacheable(key="#cardIssuserId")
	public OcsIssuer getByCardIssuserId(String cardIssuserId) {
		logger.info("getByCardIssuserId 入参:{}",cardIssuserId);
		OcsIssuer s = new OcsIssuer();
		s.setCardIssuerId(cardIssuserId);
		OcsIssuer r = ocsIssuerMapper.selectOne(s);
		if(r != null){
			return r;
		}
		return null;
	}

	@CacheEvict(allEntries=true)
	public void refreshCache() {
		logger.info("系统参数缓存已经刷新");
	}
	
}
